package com.xiguaji.tiktok.task.blogger;

import com.xiguaji.boot.eventbus.EventBusTemplate;
import com.xiguaji.tiktok.task.blogger.event.FetchBloggerAwemeEventListener;
import com.xiguaji.tiktok.task.blogger.event.FetchNewFollowerEventListener;
import com.xiguaji.tiktok.task.blogger.event.FetchNewFollowingEventListener;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BloggerTask {
    @Autowired
    EventBusTemplate eventBusTemplate;

    /**
     * 获取新用户关注列表
     *
     * @param param
     * @return
     */
    @XxlJob("fetchFollowingHandler")
    public ReturnT<String> fetchFollowingHandler(String param) {
        var fetchNewFollowingEvent = new FetchNewFollowingEventListener.FetchNewFollowingEvent(false);
        eventBusTemplate.post(fetchNewFollowingEvent);
        return ReturnT.SUCCESS;
    }

    /**
     * 循环获取用户关注列表
     *
     * @param param
     * @return
     */
    @XxlJob("fetchFollowingLoopHandler")
    public ReturnT<String> fetchFollowingLoopHandler(String param) {
        var fetchNewFollowingEvent = new FetchNewFollowingEventListener.FetchNewFollowingEvent(true);
        eventBusTemplate.post(fetchNewFollowingEvent);
        return ReturnT.SUCCESS;
    }

    /**
     * 获取新用户粉丝列表
     *
     * @param param
     * @return
     */
    @XxlJob("fetchFollowerHandler")
    public ReturnT<String> fetchFollowerHandler(String param) {
        var fetchNewFollowerEvent = new FetchNewFollowerEventListener.FetchNewFollowerEvent(false);
        eventBusTemplate.post(fetchNewFollowerEvent);
        return ReturnT.SUCCESS;
    }

    /**
     * 循环获取用户粉丝列表
     */
    @XxlJob("fetchFollowerLoopHandler")
    public ReturnT<String> fetchFollowerLoopHandler(String param) {
        var fetchNewFollowerEvent = new FetchNewFollowerEventListener.FetchNewFollowerEvent(true);
        eventBusTemplate.post(fetchNewFollowerEvent);
        return ReturnT.SUCCESS;
    }

    /**
     * 获取新用户视频列表
     *
     * @param param
     * @return
     */
    @XxlJob("fetchAwemeHandler")
    public ReturnT<String> fetchAwemeHandler(String param) {
        var fetchBloggerAwemeEvent = new FetchBloggerAwemeEventListener.FetchBloggerAwemeEvent(false);
        eventBusTemplate.post(fetchBloggerAwemeEvent);
        return ReturnT.SUCCESS;
    }

    /**
     * 循环获取用户视频列表
     */
    @XxlJob("fetchAwemeLoopHandler")
    public ReturnT<String> fetchAwemeLoopHandler(String param) {
        var fetchBloggerAwemeLoopEvent = new FetchBloggerAwemeEventListener.FetchBloggerAwemeEvent(true);
        eventBusTemplate.post(fetchBloggerAwemeLoopEvent);
        return ReturnT.SUCCESS;
    }
}
